﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ISS.Windows.Common;
using ISS.Windows.Common.Utilities;
using ISS.Common.Enviroment.Configuration;

namespace ART.Windows.HelpDesk.TicketServerCore
{
    public class Startup
    {
        public void Start(string sStartupPath)
        {
            try
            {
                Common.LocalConfig = new LocalConfig(Path.Combine((sStartupPath), "configuration.xml"));
                Common.hstCache.Add("LOGPATH", Path.Combine(Path.Combine(sStartupPath), "/Logs"));
                Common.LogObject = new CommonLogWriter();
                GetConfig();
            }
            catch (Exception ex)
            {
                ((CommonLogWriter)Common.LogObject).WriteTrace(ex.ToString());
            }

        }

        public void GetConfig()
        {
            #region lay thong so cau hinh
            try
            {
                //pop mail configuration
                Variables.POPSERVER = (string)Common.LocalConfig.ReadConfig("MailServer", "POPSERVER");
                Variables.POPPORT = (string)Common.LocalConfig.ReadConfig("MailServer", "POPPORT");
                Variables.POPUSERNAME = (string)Common.LocalConfig.ReadConfig("MailServer", "POPUSERNAME");
                Variables.POPPASSWORD = (string)Common.LocalConfig.ReadConfig("MailServer", "POPPASSWORD");
                //Variables.POPSSL = (string)Common.LocalConfig.ReadConfig("MailServer", "POPSSL").ToString().ToUpper() == "YES";

                //smtp mail configuration
                Variables.SMTPHOST = (string)Common.LocalConfig.ReadConfig("CustomerMailConfiguration", "SMTPHOST");
                Variables.SMTPPORT = (string)Common.LocalConfig.ReadConfig("CustomerMailConfiguration", "SMTPPORT");
                Variables.SMTPUSERNAME = (string)Common.LocalConfig.ReadConfig("CustomerMailConfiguration", "SMTPUSERNAME");
                Variables.SMTPPASSWORD = (string)Common.LocalConfig.ReadConfig("CustomerMailConfiguration", "SMTPPASSWORD");

            }
            catch (Exception ex)
            {
                ((CommonLogWriter)Common.LogObject).WriteTrace(ex.ToString());
            }

            #endregion
        }
    }
}
